/************************************************************************
 * AIDE - Automata Identification Engine
 * Copyright (C) 2012-2013 Ali Khalili (khalili_DOT_ir_@SIGN_gmail_DOT_com)
 * **********************************************************************
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License (LGPL) published 
 * by the Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version. This program is distributed without any
 * warranty. See the GNU Lesser General Public License for more details. 
 * ***********************************************************************
 * File         :     
 * Description  :     
 * Change log   :     	-Date:  Change
 ************************************************************************/

using System;
using SMLib.Automata.IA;

namespace AIDE.Filters.IA
{
	/// <summary>
	/// A filter for IAs which make the active and passive state separated. It disable performing
	/// an step where the state is active (i.e. an event is available).
	/// <remarks>By default when the system is in remote, it is not separated and 
	/// logically, it should be. So, use this filter
	/// in IA learning</remarks>
	/// </summary>
	/// <exception cref='NotEnabledActionException'>
	/// Is thrown when the not enabled action exception.
	/// </exception>
	public class Filter_IA_StateSep: IBlackBox_IA
	{
		IBlackBox_IA sul;
		
		/// <summary>
		/// Initializes a new instance of the <see cref="AIDE.Filters.IA.Filter_IA_StateSep"/> class.
		/// </summary>
		/// <param name='sul'>
		/// The system under learning
		/// </param>
		public Filter_IA_StateSep (IBlackBox_IA sul)
		{
			this.sul=sul;
		}

		#region IBlackBox_IA implementation
		public void Reset ()
		{
			sul.Reset();
		}

		public void Perform (SMLib.Automata.Base.ISymbol input)
		{
			if(sul.EventAvailable())
				throw new NotEnabledActionException("");
			sul.Perform(input);
		}

		public bool EventAvailable ()
		{
			return sul.EventAvailable();
		}

		public SMLib.Automata.Base.ISymbol Event ()
		{
			return sul.Event();
		}

		public SMLib.Automata.Base.Alphabet InputAlphabet {
			get {
				return sul.InputAlphabet;
			}
		}
		#endregion
	}
}

